package cn.tangsihai.feign.client;

import cn.tangsihai.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 工厂方式的托底类
 */
@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<StoreClient> {

    // 兜底方法
    @Override
    public StoreClient create(Throwable throwable) {
        return new StoreClient() {
            @Override
            public User getId(Long id) {
                throwable.printStackTrace();
                return new User(-1L, "用户服务异常");
            }
        };
    }
}
